* This script Copyright 1995 Steve Israelson
*
* This script makes stairs based on angles
*
* Set the leftSize stair default to the angle, +ve for clockwise
*		-ve for counter clockwise.
* Set the rightSize stair default to the width of the step at its outside edge
* Set the defaults florr height to the height of the last step.

* Set this to one to produce a debug output file for the script
* Debug 1

* Im too tired to comment this code, so you figure it out.
If (FloorHeight < DefaultFloorHeight)
	Repeat
		add FloorHeight StairSize
		add CeilingHeight StairSize
		If (LeftSize < 0)
			Gosub MakeCounterClockwiseStep
		Else
			Gosub MakeClockWiseStep
		Endif
	Until (FloorHeight >= DefaultFloorHeight)
Else
	Repeat
		add FloorHeight -StairSize
		add CeilingHeight -StairSize
		If (LeftSize < 0)
			Gosub MakeCounterClockwiseStep
		Else
			Gosub MakeClockWiseStep
		Endif
	Until (FloorHeight <= DefaultFloorHeight)
Endif

Subroutine MakeCounterClockwiseStep
	turn -90
	turn LeftSize
	newLine RightSize
	turn 90
	* Move by the length of the selected line
	newLine OrigLineLength
	* save this line for our new selected line
	pushLine
	lastPoint
	makeLine
	closePoly
	* make the saved line the selected line for the next step
	popLine
EndSub

Subroutine MakeClockWiseStep
	* make the poly backwards, and remember the corner point
	lastPoint
	turn -90
	turn LeftSize
	move RightSize
	pushPen
	turn -90
	move OrigLineLength
	makeLine
	
	* go back to that saved point
	popPen
	makeLine 
	pushLine
	
	lastPoint
	makeLine
	closePoly

	* make the saved line the selected line for the next step
	popLine
EndSub
